﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	///
	/// </summary>
	// Token: 0x02000178 RID: 376
	public class UserPipe : UserControl
	{
		/// <summary>
		/// 管道控件信息
		/// </summary>
		// Token: 0x06001EF5 RID: 7925 RVA: 0x00096574 File Offset: 0x00094774
		public UserPipe()
		{
			this.InitializeComponent();
			this.DoubleBuffered = true;
			this.timer.Interval = 50;
			this.timer.Tick += this.Timer_Tick;
			this.timer.Start();
		}

		/// <summary>
		/// 获取或设置管道线的宽度。
		/// </summary>
		// Token: 0x17000663 RID: 1635
		// (get) Token: 0x06001EF6 RID: 7926 RVA: 0x00096634 File Offset: 0x00094834
		// (set) Token: 0x06001EF7 RID: 7927 RVA: 0x0009664C File Offset: 0x0009484C
		[Browsable(true)]
		[Description("获取或设置管道线的宽度")]
		[Category("外观")]
		[DefaultValue(5f)]
		public float LineWidth
		{
			get
			{
				return this.lineWidth;
			}
			set
			{
				bool flag = value > 0f;
				if (flag)
				{
					this.lineWidth = value;
					base.Invalidate();
				}
			}
		}

		/// <summary>
		/// 获取或设置管道线是否处于活动状态。
		/// </summary>
		// Token: 0x17000664 RID: 1636
		// (get) Token: 0x06001EF8 RID: 7928 RVA: 0x00096678 File Offset: 0x00094878
		// (set) Token: 0x06001EF9 RID: 7929 RVA: 0x00096690 File Offset: 0x00094890
		[Browsable(true)]
		[Description("获取或设置管道线是否处于活动状态")]
		[Category("外观")]
		[DefaultValue(true)]
		public bool IsActive
		{
			get
			{
				return this.isActive;
			}
			set
			{
				this.isActive = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置管道活动状态的颜色。
		/// </summary>
		// Token: 0x17000665 RID: 1637
		// (get) Token: 0x06001EFA RID: 7930 RVA: 0x000966A4 File Offset: 0x000948A4
		// (set) Token: 0x06001EFB RID: 7931 RVA: 0x000966BC File Offset: 0x000948BC
		[Browsable(true)]
		[Description("获取或设置管道活动状态的颜色")]
		[Category("外观")]
		[DefaultValue(typeof(Color), "Blue")]
		public Color ActiveColor
		{
			get
			{
				return this.activeColor;
			}
			set
			{
				this.activeColor = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置管道的背景色
		/// </summary>
		// Token: 0x17000666 RID: 1638
		// (get) Token: 0x06001EFC RID: 7932 RVA: 0x000966D0 File Offset: 0x000948D0
		// (set) Token: 0x06001EFD RID: 7933 RVA: 0x000966E8 File Offset: 0x000948E8
		[Browsable(true)]
		[Description("获取或设置管道的背景色")]
		[Category("外观")]
		[DefaultValue(typeof(Color), "(150, 150, 150 )")]
		public Color LineColor
		{
			get
			{
				return this.lineColor;
			}
			set
			{
				this.lineColor = value;
			}
		}

		/// <summary>
		/// 获取或设置管道线的移动速度。该速度和管道的宽度有关
		/// </summary>
		// Token: 0x17000667 RID: 1639
		// (get) Token: 0x06001EFE RID: 7934 RVA: 0x000966F4 File Offset: 0x000948F4
		// (set) Token: 0x06001EFF RID: 7935 RVA: 0x0009670C File Offset: 0x0009490C
		[Browsable(true)]
		[Description("获取或设置管道线的移动速度。该速度和管道的宽度有关")]
		[Category("外观")]
		[DefaultValue(1f)]
		public float MoveSpeed
		{
			get
			{
				return this.moveSpeed;
			}
			set
			{
				this.moveSpeed = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置管道线的坐标。
		/// </summary>
		// Token: 0x17000668 RID: 1640
		// (get) Token: 0x06001F00 RID: 7936 RVA: 0x00096720 File Offset: 0x00094920
		// (set) Token: 0x06001F01 RID: 7937 RVA: 0x000967DC File Offset: 0x000949DC
		[Browsable(true)]
		[Description("获取或设置管道线的坐标，格式为0,0;1,1;2,2 分号间隔点")]
		[DefaultValue("")]
		[Category("外观")]
		public string LinePoints
		{
			get
			{
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < this.points.Count; i++)
				{
					stringBuilder.Append(";");
					stringBuilder.Append(this.points[i].X.ToString());
					stringBuilder.Append(",");
					stringBuilder.Append(this.points[i].Y.ToString());
				}
				bool flag = stringBuilder.Length > 0;
				string result;
				if (flag)
				{
					result = stringBuilder.ToString().Substring(1);
				}
				else
				{
					result = string.Empty;
				}
				return result;
			}
			set
			{
				try
				{
					bool flag = !string.IsNullOrEmpty(value);
					if (flag)
					{
						this.points.Clear();
						string[] array = value.Split(new char[]
						{
							';'
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int i = 0; i < array.Length; i++)
						{
							string[] array2 = array[i].Split(new char[]
							{
								','
							}, StringSplitOptions.RemoveEmptyEntries);
							Point item = default(Point);
							item.X = Convert.ToInt32(array2[0]);
							item.Y = Convert.ToInt32(array2[1]);
							this.points.Add(item);
						}
						base.Invalidate();
					}
				}
				catch
				{
				}
			}
		}

		// Token: 0x06001F02 RID: 7938 RVA: 0x0009689C File Offset: 0x00094A9C
		private void UserPipe_Paint(object sender, PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				Graphics graphics = e.Graphics;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				Pen pen = new Pen(this.lineColor, this.lineWidth);
				bool flag2 = this.points.Count > 1;
				if (flag2)
				{
					graphics.DrawLines(pen, this.points.ToArray());
				}
				bool flag3 = this.isActive;
				if (flag3)
				{
					pen.DashStyle = DashStyle.Dash;
					pen.DashPattern = new float[]
					{
						5f,
						5f
					};
					pen.DashOffset = this.startOffect;
					pen.Color = this.activeColor;
					bool flag4 = this.points.Count > 1;
					if (flag4)
					{
						graphics.DrawLines(pen, this.points.ToArray());
					}
				}
				pen.Dispose();
			}
		}

		// Token: 0x06001F03 RID: 7939 RVA: 0x00009AA1 File Offset: 0x00007CA1
		private void UserPipe_Load(object sender, EventArgs e)
		{
		}

		// Token: 0x06001F04 RID: 7940 RVA: 0x00096988 File Offset: 0x00094B88
		private void Timer_Tick(object sender, EventArgs e)
		{
			this.startOffect -= this.moveSpeed;
			bool flag = this.startOffect <= -10f || this.startOffect >= 10f;
			if (flag)
			{
				this.startOffect = 0f;
			}
			base.Invalidate();
		}

		/// <summary>
		/// 绘制
		/// </summary>
		/// <param name="g"></param>
		// Token: 0x06001F05 RID: 7941 RVA: 0x000969E0 File Offset: 0x00094BE0
		public void OnPaintMainWindow(Graphics g)
		{
			g.TranslateTransform((float)base.Location.X, (float)base.Location.Y);
			this.UserPipe_Paint(null, new PaintEventArgs(g, default(Rectangle)));
			g.TranslateTransform((float)(-(float)base.Location.X), (float)(-(float)base.Location.Y));
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001F06 RID: 7942 RVA: 0x00096A54 File Offset: 0x00094C54
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要修改
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001F07 RID: 7943 RVA: 0x00096A8C File Offset: 0x00094C8C
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			base.Name = "UserPipe";
			base.Size = new Size(635, 371);
			base.Load += this.UserPipe_Load;
			base.Paint += this.UserPipe_Paint;
			base.ResumeLayout(false);
		}

		// Token: 0x0400070A RID: 1802
		private List<Point> points = new List<Point>();

		// Token: 0x0400070B RID: 1803
		private Timer timer = new Timer();

		// Token: 0x0400070C RID: 1804
		private float startOffect = 0f;

		// Token: 0x0400070D RID: 1805
		private float lineWidth = 5f;

		// Token: 0x0400070E RID: 1806
		private float moveSpeed = 1f;

		// Token: 0x0400070F RID: 1807
		private Color activeColor = Color.Blue;

		// Token: 0x04000710 RID: 1808
		private bool isActive = true;

		// Token: 0x04000711 RID: 1809
		private Color lineColor = Color.FromArgb(150, 150, 150);

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x04000712 RID: 1810
		private IContainer components = null;
	}
}
